<?php


Route::get('/', function () {
    return view('welcome');
});

//前台
Route::group(['namespace'=>'Home'],function (){
    //html生成pdf
    Route::get('/pdfoutput','PdfController@make');

    //用户模块
    //登录
    Route::get('/login','LoginController@index')->name('login');
    Route::post('/login','LoginController@login');
    //登出
    Route::get('/logout','LoginController@logout');
    //注册
    Route::get('/register','RegisterController@index');
    Route::post('/register','RegisterController@register');

    Route::group(['middleware'=>'auth:web'],function (){
        //文章列表
        Route::get('/posts','PostController@index');
        //创建文章
        Route::get('/posts/create','PostController@create');
        Route::post('/posts','PostController@store');
        //文章详情
        Route::get('/posts/{post}','PostController@show');
        //编辑文章
        Route::get('/posts/{post}/edit','PostController@edit');
        Route::put('/posts/{post}','PostController@update');
        //文章删除
        Route::get('/posts/{post}/delete','PostController@delete');
        //图片上传
        Route::post('/posts/image/upload','PostController@imageupload');
        //文章评论
        Route::post('/posts/{post}/comment','PostController@comment');
        //文章赞
        Route::get('/posts/{post}/zan','PostController@zan');
        Route::get('/posts/{post}/unzan','PostController@unzan');

        //个人中心
        Route::get('/user/{user}','UserController@show');
        //个人设置
        Route::get('/user/{user}/setting','UserController@setting');
        Route::get('/user/{user}/store','UserController@store');
        //关注/取消关注
        Route::post('/user/{user}/fan','UserController@fan');
        Route::post('/user/{user}/unfan','UserController@unfan');
        //专题模块
        //专题详情页
        Route::get('/topic/{topic}','TopicController@show');
        //投稿
        Route::get('/topic/{topic}/submit','TopicController@submit');

        //通知模块
        Route::get('/notices','NoticeController@index');
    });

});
$prefix=config('website.route.prefix.admin');
Route::group(['namespace'=>'Backend','prefix'=>$prefix,'as'=>'admin::'],function (){
    //后台登录
    Route::get('/login','LoginController@index');
    Route::post('/login','LoginController@login');
    //登出
    Route::get('/logout','LoginController@logout');

    Route::group(['middleware'=>'auth:admin'],function (){
        //后台首页
        Route::get('/','IndexController@index');
        Route::get('/main','IndexController@main');
        //管理人员模块
        Route::get('/users','UserController@index')->name('user.list');
        //创建页面
        Route::get('/users/create','UserController@create')->name('user.add');
        //创建行为
        Route::post('/users/store','UserController@store');
        //编辑页面
        Route::get('/users/{adminUser}/edit','UserController@edit')->where('adminUser','[0-9]+')->name('user.edit');
        //编辑行为
        Route::put('/users/{adminUser}','UserController@update');

        //删除行为
        Route::post('/users/delete','UserController@destroy')->name('user.delete');

        //角色模块
        Route::get('/roles','RoleController@index')->name('role.list');
        Route::get('/roles/{role}/edit','RoleController@edit')->name('role.edit');
        Route::get('/roles/create','RoleController@create')->name('role.add');
        Route::post('/roles/store','RoleController@store');
        Route::post('/roles/{role}/permission','RoleController@storePermission');

        Route::put('/roles/{role}','RoleController@update');
        Route::post('/roles/delete','RoleController@destroy');

        //权限模块
        Route::get('/permissions','PermissionController@index')->name('permission.list');
        Route::get('/permissions/create','PermissionController@create')->name('permission.add');
        Route::post('/permissions/store','PermissionController@store');

        //通知模块
        Route::resource('/notices','NoticeController');







    });


});

